// 贪心
class Solution {
public:
    int hIndex(vector<int>& citations) {
        int n = citations.size();
        // 1 <= h <= n
        int h = n;
        int ans;
        while(h)
        {
            int count = 0;
            for(int i = 0; i < n; ++i)
            {
                if(citations[i] >= h)
                {
                    ++count;
                }
            }
            if(count >= h)
            {
                ans = h;
                break;
            }
            --h;
        }
        return ans;
    }
};
